<style lang="less" scoped>
.report-view {
  width: 100%;
  height: 100%;
  /deep/.el-table__inner-wrapper {
    height: 100% !important;
  }
  .pagination-css {
    padding: 5px;
    box-sizing: border-box;
    background-color: #fff;
    display: flex;
    justify-content: right;
    margin-top: 5px;
  }
}
</style>

<template>
  <div class="report-view">
    <el-form
      :inline="true"
      :model="formInline"
      class="demo-form-inline form-css"
    >
      <el-form-item label="关键字：">
        <el-input v-model="formInline.keyword" placeholder="" />
      </el-form-item>
      <el-form-item label="检查时间：">
        <el-date-picker
          v-model="formInline.inspectionTime"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          style="width: 300px"
        />
      </el-form-item>
      <el-form-item label="上传时间：">
        <el-date-picker
          v-model="formInline.uploadTime"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          style="width: 300px"
        />
      </el-form-item>
      <el-form-item label="报告时间：">
        <el-date-picker
          v-model="formInline.reportTime"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          style="width: 300px"
        />
      </el-form-item>
      <el-form-item label="项目点名称：">
        <el-input v-model="formInline.projectName" placeholder="" />
      </el-form-item>
      <el-form-item label="审核机构名称：">
        <el-input v-model="formInline.auditorName" placeholder="" />
      </el-form-item>
      <el-form-item label="审核医师：">
        <el-input v-model="formInline.auditorDoctor" placeholder="" />
      </el-form-item>
      <el-form-item label="报告状态：">
        <el-select v-model="formInline.reportStatus" placeholder="">
          <el-option
            v-for="item in statusList"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="">
        <el-button type="primary" @click="search"
          ><el-icon style="margin-right: 6px"><Search /></el-icon>
          搜索</el-button
        >
        <el-button @click="reset"
          ><el-icon style="margin-right: 6px"><Refresh /></el-icon>
          重置</el-button
        >
        <el-button>
          <!-- <el-icon style="margin-right: 6px"><Document /></el-icon> -->
          <img
            style="margin-right: 6px; width: 12px"
            src="@/images/daochu.png"
            alt=""
          />

          导出</el-button
        >
      </el-form-item>
    </el-form>
    <div class="filter-column">
      <el-popover
        placement="bottom"
        title="筛选条件"
        :width="150"
        trigger="click"
      >
        <el-checkbox-group v-model="filtrateList">
          <el-checkbox label="name">条码</el-checkbox>
          <el-checkbox label="name">项目类型</el-checkbox>
          <el-checkbox label="name">姓名</el-checkbox>
          <el-checkbox label="name">性别</el-checkbox>
          <el-checkbox label="name">年龄</el-checkbox>
          <el-checkbox label="name">检查时间</el-checkbox>
          <el-checkbox label="name">项目点名称</el-checkbox>
          <el-checkbox label="name">检查医师</el-checkbox>
          <el-checkbox label="name">上传时间</el-checkbox>
          <el-checkbox label="name">分析医师</el-checkbox>
          <el-checkbox label="name">报告时间</el-checkbox>
          <el-checkbox label="name">审核机构名称</el-checkbox>
          <el-checkbox label="name">审核医师</el-checkbox>
          <el-checkbox label="name">报告状态</el-checkbox>
        </el-checkbox-group>
      <template #reference>
          <el-button type="text"
            ><div class="shaixuan">
              <img src="@/images/shaixuan.png" alt="" /> 筛选列
            </div></el-button
          >
        </template>
      </el-popover>
    </div>
    <el-table
      v-loading="tableLoading"
      :data="tableData"
      :header-cell-style="{ backgroundColor: '#EEF6FF' }"
      stripe
      border
      height="calc(100% - 228px)"
      style="width: 100%; padding: 10px"
    >
      <el-table-column type="index" width="50" align="center" />
      <el-table-column prop="name" label="条码" align="center" />
      <el-table-column prop="address" label="项目类型" align="center" />
      <el-table-column
        v-if="filtrateList.includes('name')"
        prop="address"
        label="姓名"
        align="center"
      />
      <el-table-column prop="address" label="性别" align="center" />
      <el-table-column prop="address" label="年龄" align="center" />
      <el-table-column prop="address" label="检查时间" align="center" />
      <el-table-column
        prop="address"
        label="项目点名称"
        min-width="100px"
        align="center"
      />
      <el-table-column prop="address" label="检查医师" align="center" />
      <el-table-column prop="address" label="上传时间" align="center" />
      <el-table-column prop="address" label="分析医师" align="center" />
      <el-table-column prop="address" label="报告时间" align="center" />
      <el-table-column
        prop="address"
        label="审核机构名称"
        min-width="110px"
        align="center"
      />
      <el-table-column prop="address" label="审核医师" align="center" />
      <el-table-column prop="address" label="报告状态" align="center" />
      <el-table-column label="操作" align="center">
        <template #default="{ row }">
          <el-button type="primary" link @click="startAudit(row)"
            >开始审核</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      v-model:current-page="pageList.current"
      v-model:page-size="pageList.size"
      :page-sizes="[20, 40, 60, 80]"
      small="small"
      layout="total, sizes, prev, pager, next, jumper"
      :total="pageList.total"
      class="pagination-css"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<script>
import { getUltraSoundList } from "@/apis/reportReview";
export default {
  data() {
    return {
      filtrateList: ["name"],
      formInline: {
        keyword: "",
        inspectionTime: [],
        uploadTime: [],
        reportTime: [],
        projectName: "",
        auditorName: "",
        auditorDoctor: "",
        reportStatus: "",
      },
      tableData: [{}, {}],
      tableLoading: false,
      pageList: {
        current: 1,
        size: 20,
        total: 0,
      },
      statusList: [
        {
          label: "待审核",
          value: 1,
        },
        {
          label: "审核通过已上传",
          value: 2,
        },
        {
          label: "审核通过上传失败",
          value: 3,
        },
      ],
    };
  },
  mounted() {
    this.init();
  },
  methods: {
    init() {
      // this.getTableData()
    },
    getTableData() {
      this.tableData = [];
      this.tableLoading = true;
      getUltraSoundList({
        page: this.pageList.current, // 当前页
        size: this.pageList.size, // 每页size
        uname: this.$store.getters.name, // 登录用户
        insname: this.$store.getters.insname, //用户机构名
        keyword: this.formInline.keyword ? this.formInline.keyword : "", // 关键字
        inspectionStime: this.formInline.inspectionTime
          ? this.formInline.inspectionTime[0]
            ? this.formInline.inspectionTime[0]
            : ""
          : "", // 检查开始时间
        inspectionEtime: this.formInline.inspectionTime
          ? this.formInline.inspectionTime[1]
            ? this.formInline.inspectionTime[1]
            : ""
          : "", // 检查结束时间
        uploadStime: this.formInline.uploadTime
          ? this.formInline.uploadTime[0]
            ? this.formInline.uploadTime[0]
            : ""
          : "", //上传开始时间
        uploadEtime: this.formInline.uploadTime
          ? this.formInline.uploadTime[1]
            ? this.formInline.uploadTime[1]
            : ""
          : "", //上传结束时间
        reportStime: this.formInline.reportTime
          ? this.formInline.reportTime[0]
            ? this.formInline.reportTime[0]
            : ""
          : "", //报告开始时间
        reportEtime: this.formInline.reportTime
          ? this.formInline.reportTime[1]
            ? this.formInline.reportTime[1]
            : ""
          : "", //报告结束时间
        projectName: this.formInline.projectName
          ? this.formInline.projectName
          : "", //项目点名称
        auditorName: this.formInline.auditorName
          ? this.formInline.auditorName
          : "", //审核机构名称
        auditorDoctor: this.formInline.auditorDoctor
          ? this.formInline.auditorDoctor
          : "", //审核医师
        reportStatus: this.formInline.reportStatus
          ? this.formInline.reportStatus
          : "", //报告状态
      }).then((res) => {
        if (res.code == 0) {
          if (res.data && res.data.length > 0) {
            this.tableData = res.data;
            this.pageList.total = res.size;
            this.tableLoading = false;
          }
        }
      });
    },
    // 搜索
    search() {
      this.pageList.current = 1;
      this.getTableData();
    },
    // 重置
    reset() {
      this.formInline.keyword = "";
      this.formInline.inspectionTime = [];
      this.formInline.uploadTime = [];
      this.formInline.reportTime = [];
      this.formInline.projectName = "";
      this.formInline.auditorName = "";
      this.formInline.auditorDoctor = "";
      this.formInline.reportStatus = "";
      this.pageList.current = 1;
      this.pageList.size = 20;
      this.getTableData();
    },
    startAudit(row) {
      console.log(row.name, "scope");
      this.$router.push("/reportDetails");
    },
    handleSizeChange(val) {
      this.pageList.current = 1;
      this.pageList.size = val;
      this.getTableData();
    },
    handleCurrentChange(val) {
      this.pageList.current = val;
      this.getTableData();
    },
  },
};
</script>
